#include<bits/stdc++.h>
using namespace std;
using ll = long long;
struct pp{
	ll r,c;
}a[1100];
int main()
{
	ll T=1;
	cin >> T;
	while(T--)
	{
		ll n,s;
		cin >> n >> s;
		ll cnt1=0,cntfs=0;
		for(ll i=1;i<=n;i++)
		{
			cin >> a[i].r>> a[i].c;	
			if(a[i].r==1)
			{
				cnt1++;
			}
			cntfs+=a[i].c;
		}
		if(n%2!=1)
        {
            if(cnt1>=n/2)
		{
			cout<<"1 ";
		}
		else {
			cout<<"0 ";
		}
        }
        else {
            ll sss=n/2+1;
            if(cnt1>=sss)
		{
			cout<<"1 ";
		}
		else {
			cout<<"0 ";
		}
        }
		
		if(cntfs-50>=s)
		{
			cout<<"1\n";
		}
		else {
			cout<<"0\n";
		}
	}
}
